﻿Imports Microsoft.VisualBasic
Imports System.Data.SqlClient
Imports System.Data
Imports SV_Global.SQL

Namespace SV_Global.Global
    Public Class Usuario

#Region "Membros Da Classe"

        Private _UsuarioID As Integer
        Private _Nome As String
        Private _Email As String
        Private _CPF As Integer
        Private _Login As String
        Private _Senha As String
        Private _DataNascimento As Date
        Private _Sexo As String
        Private _Sobre As String
        Private _DataCadastro As Date
        Private _Docente As Boolean
        Private _Administrador As Boolean
        Private _Ativo As Boolean

#End Region

#Region "Propriedades"

        Public Property UsuarioID() As Integer
            Get
                Return _UsuarioID
            End Get
            Set(ByVal value As Integer)
                _UsuarioID = value
            End Set
        End Property

        Public Property Nome() As String
            Get
                Return _Nome
            End Get
            Set(ByVal value As String)
                _Nome = value
            End Set
        End Property

        Public Property Email() As String
            Get
                Return _Email
            End Get
            Set(ByVal value As String)
                _Email = value
            End Set
        End Property

        Public Property CPF() As Integer
            Get
                Return _CPF
            End Get
            Set(ByVal value As Integer)
                _CPF = value
            End Set
        End Property

        Public Property Login() As String
            Get
                Return _Login
            End Get
            Set(ByVal value As String)
                _Login = value
            End Set
        End Property

        Public Property Senha() As String
            Get
                Return _Senha
            End Get
            Set(ByVal value As String)
                _Senha = value
            End Set
        End Property

        Public Property DataNascimento() As Date
            Get
                Return _DataNascimento
            End Get
            Set(ByVal value As Date)
                _DataNascimento = value
            End Set
        End Property

        Public Property Sexo() As String
            Get
                Return _Sexo
            End Get
            Set(ByVal value As String)
                _Sexo = value
            End Set
        End Property

        Public Property Sobre() As String
            Get
                Return _Sobre
            End Get
            Set(ByVal value As String)
                _Sobre = value
            End Set
        End Property

        Public Property DataCadastro() As Date
            Get
                Return _DataCadastro
            End Get
            Set(ByVal value As Date)
                _DataCadastro = value
            End Set
        End Property

#End Region

#Region "Construtores"

        Public Sub New()
        End Sub

        Public Sub New(ByVal intUsuarioID As Integer)
            Me.Exibir(intUsuarioID)
        End Sub

#End Region

#Region "Funções"

        ''' <summary>
        ''' Adiciona Usuário Ao Banco De Dados
        ''' </summary>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Sub Adicionar()
            Dim Parametros = New ArrayList
            With Parametros
                .Add(New SqlParameter("@Nome", _Nome))
                .Add(New SqlParameter("@Email", _Email))
                .Add(New SqlParameter("@CPF", _CPF))
                .Add(New SqlParameter("@Login", _Login))
                .Add(New SqlParameter("@Senha", _Senha))
                .Add(New SqlParameter("@DataNascimento", _DataNascimento))
                .Add(New SqlParameter("@Sexo", _Sexo))
                .Add(New SqlParameter("@DataCadastro", _DataCadastro))
                .Add(New SqlParameter("@Docente", _Docente))
                .Add(New SqlParameter("@Administrador", _Administrador))
                .Add(New SqlParameter("@Ativo", _Ativo))
            End With
            Dim Reader = StoredProcedures.retornaDataReader("SV_UsuariosAdicionar", Parametros)
            While Reader.Read
                UsuarioID = Val(Reader(0).ToString)
            End While
        End Sub

        ''' <summary>
        ''' Edita Usuário No Banco De Dados
        ''' </summary>
        ''' <param name="UsuarioID"></param>
        ''' <remarks></remarks>
        Public Sub Editar(ByVal UsuarioID As Integer)
            Dim Parametros = New ArrayList
            With Parametros
                .Add(New SqlParameter("@UsuarioID", UsuarioID))
                .Add(New SqlParameter("@Nome", _Nome))
                .Add(New SqlParameter("@Email", _Email))
                .Add(New SqlParameter("@CPF", _CPF))
                .Add(New SqlParameter("@Login", _Login))
                .Add(New SqlParameter("@Senha", _Senha))
                .Add(New SqlParameter("@DataNascimento", _DataNascimento))
                .Add(New SqlParameter("@Sexo", _Sexo))
                .Add(New SqlParameter("@DataCadastro", _DataCadastro))
                .Add(New SqlParameter("@Docente", _Docente))
                .Add(New SqlParameter("@Administrador", _Administrador))
                .Add(New SqlParameter("@Ativo", _Ativo))
            End With
            Dim Reader = StoredProcedures.retornaDataReader("SV_UsuariosEditar", Parametros)
        End Sub

        ''' <summary>
        ''' Marca Usuário Com O Campo Ativo = False
        ''' </summary>
        ''' <param name="UsuarioID"></param>
        ''' <remarks></remarks>
        Public Sub Excluir(ByVal UsuarioID As Integer)
            Dim Parametros = New ArrayList
            With Parametros
                .Add(New SqlParameter("@UsuarioID", UsuarioID))
            End With
            Dim Reader = StoredProcedures.retornaDataReader("SV_UsuariosExcluir", Parametros)
        End Sub

        ''' <summary>
        ''' Exclúi Usuário Fisicamente No Banco De Dados
        ''' </summary>
        ''' <param name="UsuarioID"></param>
        ''' <remarks></remarks>
        Public Sub ExcluirFisico(ByVal UsuarioID As Integer)
            Dim Parametros = New ArrayList
            With Parametros
                .Add(New SqlParameter("@UsuarioID", UsuarioID))
            End With
            Dim Reader = StoredProcedures.retornaDataReader("SV_UsuariosExcluirFisico", Parametros)
        End Sub

        Public Sub Exibir(ByVal intUsuarioID As Integer)

        End Sub

        Public Overloads Function Buscar(Optional ByVal UsuNome As String = "") As ArrayList

        End Function


        Public Overloads Function Buscar(ByVal intDepartamentoID As Integer) As ArrayList


        End Function

        Public Function AlteraSenha(ByVal strSenhaNova As String) As Boolean

        End Function

#End Region

    End Class
End Namespace


